<template>
  <app-home>
    <div slot="main">
      <app-table :datas="msg" ref="clickRemove"></app-table>
    </div>
  </app-home>
</template>


<script>
import Home from "@/views/home";
// import moment from "moment";
import table from "@/components/table.vue";

export default {
  components: {
    "app-home": Home,
    "app-table": table
  },
  data() {
    return {
      msg: {
        deleBtn: false,
        columns: [
          {
            type: "selection",
            width: 60,
            align: "center"
          },
          {
            title: "产品名称",
            key: "name"
          },
          {
            title: "产品类型",
            key: "product_type" 
          },

          {
            title: "购买数量",
            key: "buy_num"
          },
          {
            title: "火热程度",
            key: "hot",
            render: (h, params) => {
              if (params.row.hot) {
                return h("div", "爆款");
              } else {
                return h("div", "一般");
              }
            }
          },
          {
            title: "上架日期",
            key: "pro_data"
          },
          {
            title: "地址",
            key: "source"
          },
          {
            title: "价格",
            key: "price"
          },
          {
            title: "操作",
            key: "action",
            width: 150,
            align: "center",
            render: (h, params) => {
              return h("div", [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.update(params.row);
                      }
                    }
                  },
                  "编辑"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "error",
                      size: "small"
                    },
                    on: {
                      click: () => {
                         this.$refs.clickRemove.remove(params.row._id);
                      }
                    }
                  },
                  "删除"
                )
              ]);
            }
          }
        ],
        rows: [],
        total: 0,
        page: 1,
        limit: 10,
        selectionArray: [], //多个删除数组,
        Delete: "ProductDelete", //删除单项用户函数
        List: "productList", //获取用户数据函数
        Removes: "productRemoves" //移除多个用户数据函数
      }
    };
  }
};
</script>
